home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 4 / QRZ Ham Radio Callsign Database - Volume 4.iso / files / tcpip / amiga / asrc29p.lha / ip.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-29  |  6.2 KB  |  186 lines

  1. #ifndef    NROUTE
  2.  
  3. #include "global.h"
  4. #include "internet.h"
  5. #include "timer.h"
  6.  
  7. #define    NROUTE    5    /* Number of hash chains in routing table */
  8. #define    TLB    30    /* Default reassembly timeout, sec */
  9. #define    IPVERSION    4
  10.  
  11. extern int32 Ip_addr;    /* Our IP address for ICMP and source routing */
  12.  
  13. /* SNMP MIB variables, used for statistics and control. See RFC 1066 */
  14. extern struct mib_entry Ip_mib[];
  15. #define    ipForwarding        Ip_mib[1].value.integer
  16. #define    ipDefaultTTL        Ip_mib[2].value.integer
  17. #define    ipInReceives        Ip_mib[3].value.integer
  18. #define    ipInHdrErrors        Ip_mib[4].value.integer
  19. #define    ipInAddrErrors        Ip_mib[5].value.integer
  20. #define    ipForwDatagrams        Ip_mib[6].value.integer
  21. #define    ipInUnknownProtos    Ip_mib[7].value.integer
  22. #define    ipInDiscards        Ip_mib[8].value.integer
  23. #define    ipInDelivers        Ip_mib[9].value.integer
  24. #define    ipOutRequests        Ip_mib[10].value.integer
  25. #define    ipOutDiscards        Ip_mib[11].value.integer
  26. #define    ipOutNoRoutes        Ip_mib[12].value.integer
  27. #define    ipReasmTimeout        Ip_mib[13].value.integer
  28. #define    ipReasmReqds        Ip_mib[14].value.integer
  29. #define    ipReasmOKs        Ip_mib[15].value.integer
  30. #define    ipReasmFails        Ip_mib[16].value.integer
  31. #define    ipFragOKs        Ip_mib[17].value.integer
  32. #define    ipFragFails        Ip_mib[18].value.integer
  33. #define    ipFragCreates        Ip_mib[19].value.integer
  34.  
  35. #define    NUMIPMIB    19
  36.  
  37. /* IP header, INTERNAL representation */
  38. struct ip {
  39.     char version;        /* IP version number */
  40.     char tos;        /* Type of service */
  41.     int16 length;        /* Total length */
  42.     int16 id;        /* Identification */
  43.     int16 offset;        /* Fragment offset in bytes */
  44.     struct {
  45.         char df;    /* Don't fragment flag */
  46.         char mf;    /* More Fragments flag */
  47.     } flags;
  48.  
  49.     char ttl;        /* Time to live */
  50.     char protocol;        /* Protocol */
  51.     int16 checksum;        /* Header checksum */
  52.     int32 source;        /* Source address */
  53.     int32 dest;        /* Destination address */
  54.     char options[44];    /* Options field */
  55.     int16 optlen;        /* Length of options field, bytes */
  56. };
  57. #define    NULLIP    (struct ip *)0
  58. #define    IPLEN    20    /* Length of standard IP header */
  59.  
  60. /* Fields in option type byte */
  61. #define    OPT_COPIED    0x80    /* Copied-on-fragmentation flag */
  62. #define    OPT_CLASS    0x60    /* Option class */
  63. #define    OPT_NUMBER    0x1f    /* Option number */
  64.  
  65. /* IP option numbers */
  66. #define    IP_EOL        0    /* End of options list */
  67. #define    IP_NOOP        1    /* No Operation */
  68. #define    IP_SECURITY    2    /* Security parameters */
  69. #define    IP_LSROUTE    3    /* Loose Source Routing */
  70. #define    IP_TIMESTAMP    4    /* Internet Timestamp */
  71. #define    IP_RROUTE    7    /* Record Route */
  72. #define    IP_STREAMID    8    /* Stream ID */
  73. #define    IP_SSROUTE    9    /* Strict Source Routing */
  74.  
  75. /* Timestamp option flags */
  76. #define    TS_ONLY        0    /* Time stamps only */
  77. #define    TS_ADDRESS    1    /* Addresses + Time stamps */
  78. #define    TS_PRESPEC    3    /* Prespecified addresses only */
  79.  
  80. /* IP routing table entry */
  81. struct route {
  82.     struct route *prev;    /* Linked list pointers */
  83.     struct route *next;
  84.     int32 target;        /* Target IP address */
  85.     unsigned int bits;    /* Number of significant bits in target */
  86.     int32 gateway;        /* IP address of local gateway for this target */
  87.     int32 metric;        /* Hop count or whatever */
  88.     struct iface *iface;    /* Device interface structure */
  89.     int flags;
  90. #define    RTPRIVATE    0x1    /* Should the world be told of this route ? */
  91. #define    RTTRIG    0x2        /* Trigger is pending for this route */
  92.     struct timer timer;    /* Time until aging of this entry */
  93.     int32 uses;        /* Usage count */
  94. };
  95. #define    NULLROUTE    (struct route *)0
  96. extern struct route *Routes[32][NROUTE];    /* Routing table */
  97. extern struct route R_default;            /* Default route entry */
  98.  
  99. /* Cache for the last-used routing entry, speeds up the common case where
  100.  * we handle a burst of packets to the same destination
  101.  */
  102. struct rt_cache {
  103.     int32 target;
  104.     struct route *route;
  105. };
  106. extern struct rt_cache Rt_cache;
  107.  
  108. /* Reassembly descriptor */
  109. struct reasm {
  110.     struct reasm *next;    /* Linked list pointers */
  111.     struct reasm *prev;
  112.     struct timer timer;    /* Reassembly timeout timer */
  113.     struct frag *fraglist;    /* Head of data fragment chain */
  114.     int16 length;        /* Entire datagram length, if known */
  115.     int32 source;        /* src/dest/id/protocol uniquely describe a datagram */
  116.     int32 dest;
  117.     int16 id;
  118.     char protocol;
  119. };
  120. #define    NULLREASM    (struct reasm *)0
  121.  
  122. /* Fragment descriptor in a reassembly list */
  123. struct frag {
  124.     struct frag *prev;    /* Previous fragment on list */
  125.     struct frag *next;    /* Next fragment */
  126.     struct mbuf *buf;    /* Actual fragment data */
  127.     int16 offset;        /* Starting offset of fragment */
  128.     int16 last;        /* Ending offset of fragment */
  129. };
  130. #define    NULLFRAG    (struct frag *)0
  131.  
  132. extern struct reasm *Reasmq;    /* The list of reassembly descriptors */
  133.  
  134. /* Structure for handling raw IP user sockets */
  135. struct raw_ip {
  136.     struct raw_ip *prev;
  137.     struct raw_ip *next;
  138.  
  139.     struct mbuf *rcvq;    /* receive queue */
  140.     void (*r_upcall) __ARGS((struct raw_ip *));
  141.     int protocol;        /* Protocol */
  142.     int user;        /* User linkage */
  143. };
  144. #define    NULLRIP    ((struct raw_ip *)0)
  145. extern struct raw_ip *Raw_ip;
  146.  
  147. /* Transport protocol link table */
  148. struct iplink {
  149.     char proto;
  150.     void (*funct) __ARGS((struct iface *,struct ip *,struct mbuf *,int));
  151. };
  152. extern struct iplink Iplink[];
  153.  
  154. /* In ip.c: */
  155. void ip_recv __ARGS((struct iface *iface,struct ip *ip,struct mbuf *bp,
  156.     int rxbroadcast));
  157. int ip_send __ARGS((int32 source,int32 dest,char protocol,char tos,char ttl,
  158.     struct mbuf *bp,int16 length,int16 id,char df));
  159. struct raw_ip *raw_ip __ARGS((int protocol,void (*r_upcall) __ARGS((struct raw_ip *)) ));
  160. void del_ip __ARGS((struct raw_ip *rrp));
  161.  
  162. /* In iproute.c: */
  163. int16 ip_mtu __ARGS((int32 addr));
  164. int ip_route __ARGS((struct iface *i_iface,struct mbuf *bp,int rxbroadcast));
  165. int32 locaddr __ARGS((int32 addr));
  166. void rt_merge __ARGS((int trace));
  167. struct route *rt_add __ARGS((int32 target,unsigned int bits,int32 gateway,
  168.     struct iface *iface,int32 metric,int32 ttl,char private));
  169. int rt_drop __ARGS((int32 target,unsigned int bits));
  170. struct route *rt_lookup __ARGS((int32 target));
  171. struct route *rt_blookup __ARGS((int32 target,unsigned int bits));
  172.  
  173. /* In iphdr.c: */
  174. int16 cksum __ARGS((struct pseudo_header *ph,struct mbuf *m,int16 len));
  175. int16 eac __ARGS((int32 sum));
  176. struct mbuf *htonip __ARGS((struct ip *ip,struct mbuf *data,int cflag));
  177. int ntohip __ARGS((struct ip *ip,struct mbuf **bpp));
  178.  
  179. /* In either lcsum.c or pcgen.asm: */
  180. int16 lcsum __ARGS((int16 *wp,int16 len));
  181.  
  182. /* In ipcmd.c */
  183. void log_ipheard __ARGS((int32 addr, struct iface *iface, char *add25));
  184.  
  185. #endif /* NROUTE */
  186.